<template>
	<view class="lottery" :style="{height:`${device.screenHeight}px`}">
		<x-navigation-bar :isBack="true" bgColor="#FFF" :title="title"></x-navigation-bar>
		<view class="x-page-border-top" :style="{'margin-top': device.navigationBarHeight+'px'}"></view>

		<view class="content" :style="{height:(device.screenHeight-device.navigationBarHeight)+'px;'}">
			<!-- <image class="decorate-image" mode="widthFix" src="@/static/rule/rule_front.png"></image>
			<image class="logo" mode="widthFix" src="@/static/logo_rect.png"></image> -->

			<view class="bg"></view>
			<image src="@/static/logo_rect.png" class="logo" mode="widthFix"></image>
			<image src="@/static/rule/rule_front.png" class="front-img" mode="widthFix"></image>
			<view class="layout">
				<scroll-view scroll-y class="desc" :style="{'height':device.windowHeight-140+'px'}">
					<p class="html" v-html="content"></p>
				</scroll-view>
			</view>
		</view>

	</view>
</template>

<script>
	import XNavigationBar from '@/components/navigationBar/xNavigationBar.vue'
	import {
		getContentById
	} from '@/api/protocol.js'
	import config from '@/config';
	import {
		mapState
	} from 'vuex'

	export default {
		components: {
			XNavigationBar,
		},
		computed: {
			...mapState(['device']),
		},
		props: {
			contentId: {
				type: String,
			},
			title: {
				type: String
			},
			mode: {
				type: String
			}
		},
		data() {
			return {
				imageUrl: config.imageUrl,
				content: '',
				titleHeight: 50,
			}
		},
		mounted() {
			getContentById(this.contentId).then(res => {
				this.content = res.replaceAll('<img src=\"/images/', '<img width="100%" src="' + this.imageUrl)

				// var str = res
				// var newStr = str.replace(/(<img.*?style=")(.*?)(".*?>)/g, function(match, p1, p2, p3) {
				//   var oldStyle = p2.trim();
				//   return p1 + 'max-width:100%;height:auto;display:block;' + oldStyle + p3;
				// });
				// var newStr = newStr.replaceAll('<img src=\"/images/', '<img width="100%" src="' + this.imageUrl)
				// console.log("newStr=", newStr)
				// this.content = newStr
			})
		},
		methods: {

		}
	}
</script>


<!-- <style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		height: 100%;
	
		
	}
</style> -->

<style lang="scss" scoped>
	.content {
		position: relative;
		width: 100%;
		// background-color: #1C1A1A;

		.bg {
			background: #000;
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			z-index: -2;
		}

		.logo {
			width: 244rpx;
			position: absolute;
			left: 30rpx;
			top: 80rpx;
			z-index: -1;
		}

		.front-img {
			position: absolute;
			right: 0rpx;
			top: 0rpx;
			z-index: -1;
			width: 50%;
		}

		// .decorate-image {
		// 	position: absolute;
		// 	right: 0rpx;
		// 	top: 0rpx;
		// 	width: 50%;
		// 	opacity: 0.9;
		// }

		.layout {
			display: flex;
			flex-direction: column;
			align-items: center;
			position: absolute;
			width: 100%;
			top: 160rpx;

			.logo {
				margin-top: 80rpx;
				margin-bottom: 20rpx;
				width: 300rpx;
			}

			.desc {

				width: 700rpx;
				z-index: 100;
				border-radius: 12rpx;
				background: #F8F4E9;
			}
		}


	}

	img {
		display: block;
		float: left;
		width: 100% !important;
		// margin: 10px 0 0 10px;
	}

	.html {
		// line-height: 24px !important;
		// height: 100%; 
		// margin-top: 10rpx;
		padding: 10px !important;
		color: #363634;
		// text-indent: 24rpx !important;
		// padding: 100rpx 36rpx 40rpx !important;
	}
</style>